/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.deployment.manager.search;

import br.com.deployment.daoImpl.NotaryOfficeDAOImpl;
import br.com.deployment.entities.Address;
import br.com.deployment.entities.NotaryOffice;
import br.com.deployment.enums.TypeAdmission;
import br.com.deployment.utils.Caracter;
import br.com.deployment.utils.Msg;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;

/**
 *
 * @author ely
 */
@ManagedBean
@SessionScoped
public class ManagerEditNotaryOffice {
    
    @EJB
    NotaryOfficeDAOImpl notaryService;
    
    NotaryOffice notaryOffice;
    Address addres;
    
     TypeAdmission admission[] = TypeAdmission.values();
    
    public ManagerEditNotaryOffice(){}

    
    public void update(){
        addres.setCellular(Caracter.removecaracter(addres.getCellular()));
        addres.setCep(Caracter.removecaracter(addres.getCep()));
        addres.setPhone(Caracter.removecaracter(addres.getPhone()));
        notaryOffice.setAddress(addres);
        notaryService.update(notaryOffice);
        Msg.messagemInfo("Cartório Atualizado");
    }
    
      public void redirect(String string, NotaryOffice n) {
        try {
            FacesContext context = FacesContext.getCurrentInstance();
            this.notaryOffice = n;
            this.addres = notaryOffice.getAddress();
            context.getExternalContext().redirect(string);
        } catch (IOException ex) {
            Logger.getLogger(ManagerEditNotaryOffice.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
    public NotaryOffice getNotaryOffice() {
        return notaryOffice;
    }

    public void setNotaryOffice(NotaryOffice notaryOffice) {
        this.notaryOffice = notaryOffice;
    }

    public Address getAddres() {
        return addres;
    }

    public void setAddres(Address addres) {
        this.addres = addres;
    }

    public TypeAdmission[] getAdmission() {
        return admission;
    }

    public void setAdmission(TypeAdmission[] admission) {
        this.admission = admission;
    }
    
    
    
    
}
